﻿<?php
session_start();
include("admin_resist_mdl.php");
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?php

include("../../Modules/conn.php");

$mssv = $_POST["txtMSSV"];
$hoten = $_POST["txtHoTen"];
$mk = $_POST["txtMK1"];
$mkmh = md5($mk);

// Kiem tra mssv co bi trung hay khong
$queryMSSV = "select MSSV from sinh_vien where MSSV = '$mssv'";
$resultMSSV = mysql_query($queryMSSV, $conn) or die(mysql_error());
$count = mysql_num_rows($resultMSSV);

if ($count > 0)
{
	header("Location: ../View/admin_cpanel.php?part=addsv&info=dupmssv");
}
else
{
	// Them sinh vien
	$queryInsSV = "insert into sinh_vien(MSSV, TEN_SV, MAT_KHAU) values ('$mssv', '$hoten', '$mkmh')";
	mysql_query($queryInsSV, $conn) or die(mysql_error());
	
	mysql_close();
	header("Location: ../View/admin_cpanel.php?info=addsvsucc");
}

?>